package org.admanager.acmepattern.plugin.diagram.edit.policies;

import org.admanager.acmepattern.plugin.diagram.edit.commands.PComponentCreateCommand;
import org.admanager.acmepattern.plugin.diagram.edit.commands.PComponentPortCreateCommand;
import org.admanager.acmepattern.plugin.diagram.edit.commands.PConnectorCreateCommand;
import org.admanager.acmepattern.plugin.diagram.edit.commands.PConnectorRoleCreateCommand;
import org.admanager.acmepattern.plugin.diagram.edit.commands.PMultiplicityCreateCommand;
import org.admanager.acmepattern.plugin.diagram.edit.commands.PRoleCreateCommand;
import org.admanager.acmepattern.plugin.diagram.providers.AcmeADManagementMetamodelElementTypes;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;

/**
 * @generated
 */
public class CBAPatternItemSemanticEditPolicy extends
		AcmeADManagementMetamodelBaseItemSemanticEditPolicy {

	/**
	 * @generated
	 */
	public CBAPatternItemSemanticEditPolicy() {
		super(AcmeADManagementMetamodelElementTypes.CBAPattern_1000);
	}

	/**
	 * @generated
	 */
	protected Command getCreateCommand(CreateElementRequest req) {
		if (AcmeADManagementMetamodelElementTypes.PComponent_2007 == req
				.getElementType()) {
			return getGEFWrapper(new PComponentCreateCommand(req));
		}
		if (AcmeADManagementMetamodelElementTypes.PComponentPort_2008 == req
				.getElementType()) {
			return getGEFWrapper(new PComponentPortCreateCommand(req));
		}
		if (AcmeADManagementMetamodelElementTypes.PConnector_2009 == req
				.getElementType()) {
			return getGEFWrapper(new PConnectorCreateCommand(req));
		}
		if (AcmeADManagementMetamodelElementTypes.PConnectorRole_2010 == req
				.getElementType()) {
			return getGEFWrapper(new PConnectorRoleCreateCommand(req));
		}
		if (AcmeADManagementMetamodelElementTypes.PMultiplicity_2011 == req
				.getElementType()) {
			return getGEFWrapper(new PMultiplicityCreateCommand(req));
		}
		if (AcmeADManagementMetamodelElementTypes.PRole_2012 == req
				.getElementType()) {
			return getGEFWrapper(new PRoleCreateCommand(req));
		}
		return super.getCreateCommand(req);
	}

	/**
	 * @generated
	 */
	protected Command getDuplicateCommand(DuplicateElementsRequest req) {
		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
				.getEditingDomain();
		return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
	}

	/**
	 * @generated
	 */
	private static class DuplicateAnythingCommand extends
			DuplicateEObjectsCommand {

		/**
		 * @generated
		 */
		public DuplicateAnythingCommand(
				TransactionalEditingDomain editingDomain,
				DuplicateElementsRequest req) {
			super(editingDomain, req.getLabel(), req
					.getElementsToBeDuplicated(), req
					.getAllDuplicatedElementsMap());
		}

	}

}
